# This code is sourced by cv_ALL scripts
# in order to finish off with a status message.
# Some variables should already be set by the sourcing script.


# If TYPE is cv_ALL, then we assume we are doing a full compile
# of everything and so need to set the STATUS.txt
if [ "$TYPE" = "cv_ALL" ] ; then
    if [ -e $LIBDIR/README.txt ] ; then
        /bin/cp -f $LIBDIR/logic/etc/README.txt $LIBDIR/logic/etc/STATUS.txt
    else
       /bin/rm -f $LIBDIR/logic/etc/STATUS.txt
    fi

    echo " "	     >> $LIBDIR/logic/etc/STATUS.txt
    echo `date`" : \c"   >> $LIBDIR/logic/etc/STATUS.txt
fi   
echo $LOGFILE
if grep ': \*[EF]' $LOGFILE > /dev/null ; then
    echo "Compilation FAILED for $TYPE"		| $ADD_TO_LOG
    if [ "$TYPE" = "cv_ALL" ] ; then
	echo "Compilation FAILED"	        >> $LIBDIR/logic/etc/STATUS.txt
    fi   
else
    echo "Compilation SUCCESSFUL for $TYPE"	| $ADD_TO_LOG
    if [ "$TYPE" = "cv_ALL" ] ; then
	echo "Compilation SUCCESSFUL"       >> $LIBDIR/logic/etc/STATUS.txt
    fi   
fi


# If we are running vcanalyse, then make a link to the vhdlcover.map file
if [ "$TYPE" = "vcanalyse_ALL" ] ; then
    echo "Linking vhdlcover.map to $LIBDIR/work/vhdlcover/vhdlcover.map"
    rm -f $LIBDIR/work/vhdlcover/vhdlcover.map
    ln -s $LIBDIR/lib/vhdlcover.src/vhdlcover.map $LIBDIR/lib/vhdlcover.map
fi
